#include "StdAfx.h"
#include "CRectangle2D.h"

CRectangle2D::CRectangle2D(void){
	
	setP1(Cpunt2D(5,5));
	setP3(Cpunt2D(25,25));
}

CRectangle2D::CRectangle2D(Cpunt2D p1, Cpunt2D p3){

	setP1(p1);
	setP3(p3);
}

CRectangle2D::CRectangle2D(CSegment2D s1, CSegment2D s2){

	m_p1=s2.getPi();
	m_p3.SetX(s2.getPd().GetX());
	m_p3.SetY(s1.getPi().GetY());
}

CRectangle2D::CRectangle2D(const CSegment2D &s5){

	setP1(s5.getPi());
	setP3(s5.getPd());
}


CRectangle2D::CRectangle2D(const CRectangle2D &rec){

	setP1(rec.getP1());
	setP3(rec.getP3());
}

CRectangle2D::~CRectangle2D(void){


}

Cpunt2D CRectangle2D::getP1()const{

	return m_p1;
}

Cpunt2D CRectangle2D::getP2()const{

	return Cpunt2D(m_p3.GetX(),m_p1.GetY());
}

Cpunt2D CRectangle2D::getP3()const{

	return m_p3;
}

 Cpunt2D CRectangle2D::getP4()const{
	
	 return Cpunt2D(m_p1.GetX(),m_p3.GetY());
}

CSegment2D CRectangle2D::getS1()const{

	return CSegment2D(getP4(),getP1());
}

CSegment2D CRectangle2D::getS2()const{

	return CSegment2D(getP1(),getP2());
}

CSegment2D CRectangle2D::getS3()const{

	return CSegment2D(getP2(),getP3());
}

CSegment2D CRectangle2D::getS4()const{

	return CSegment2D(getP3(),getP4());
}


CSegment2D CRectangle2D::getS5()const{

	return CSegment2D(getP1(),getP3());
}

void CRectangle2D::setP1(const Cpunt2D p1){

	m_p1=p1;
}

void CRectangle2D::setP3(const Cpunt2D p3){
		
	m_p3=p3;
}

void CRectangle2D::setS5(const CSegment2D s5){
	
	setP1(s5.getPi());
	setP3(s5.getPd());

}

int CRectangle2D::getArea()const{

	return (int) getS2().getlong()*getS3().getlong();
	
}
	
int CRectangle2D::getPerim()const{

	return (int) (2*getS1().getlong())+(2*getS2().getlong());
}
	
CRectangle2D CRectangle2D::operator=(const CRectangle2D &r){

	setP1(r.getP1());
	setP3(r.getP3());
	return *this;
}